<?php


$router->get('/', ['uses' => 'IndexController@index', 'as' => 'steam.home']);
$router->options('/{path:.*}', ['uses' => 'IndexController@options', 'as' => 'options']);

// 通用配置等信息
$router->get('/grades', ['uses' => 'CommonController@grades', 'as' => 'common.grades']);

// lumen 不支持resource 类型，所以只能自己写了
$router->group(['prefix' => 'api/backend', 'namespace' => 'Backend'], function () use ($router) {
    /** 用户 */
    $router->post('/users/setToken', 'UsersController@setToken');                             // 设置用户登录
    $router->get('/users/getLoginStatus', 'UsersController@getLoginStatus');                  // 获取登录状态
    $router->post('/users/getMobileAgency', 'UsersController@getMobileAgency');               // 根据账号查询机构列表
    $router->get('/users/getUserInfo', 'UsersController@getUserInfo');                        // 获取员工信息
    $router->delete('/users/logout', ['uses' => 'UsersController@logout', 'as' => 'backend.users.logout']);// 退出登录
    $router->get('/users/{id}', ['uses' => 'UsersController@show', 'as' => 'backend.users.show']);

    // 访客记录 [暂不支持访客]
    $router->get('/visitors', ['uses' => 'VisitorsController@index', 'as' => 'backend.visitors.index']);
    $router->get('/visitors/{id}', ['uses' => 'VisitorsController@show', 'as' => 'backend.visitors.show']);
    $router->patch('/visitors/{id}', ['uses' => 'VisitorsController@update', 'as' => 'backend.visitors.update']);
    $router->get('/visitor/tags', ['uses' => 'VisitorController@tags', 'as' => 'backend.visitors.tags.index']);
    $router->post('/visitor/tags', ['uses' => 'VisitorController@tagStore', 'as' => 'backend.visitors.tags.store']);

    // 课程
    $router->get('/courses', ['uses' => 'CoursesController@index', 'as' => 'backend.courses.index']);
    $router->get('/courses/{id}', ['uses' => 'CoursesController@show', 'as' => 'backend.courses.show']);
    $router->post('/courses', ['uses' => 'CoursesController@create', 'as' => 'backend.courses.store']);
    $router->patch('/courses/{id}', ['uses' => 'CoursesController@update', 'as' => 'backend.courses.update']);
    $router->delete('/courses/{id}', ['uses' => 'CoursesController@destroy', 'as' => 'backend.courses.destroy']);

    // 课程标签
    $router->get('/course/tags', ['uses' => 'CourseTagsController@index', 'as' => 'backend.course.tags.index']);
    $router->get('/course/tags/{id}', ['uses' => 'CourseTagsController@show', 'as' => 'backend.course.tags.show']);
    $router->post('/course/tags', ['uses' => 'CourseTagsController@create', 'as' => 'backend.course.tags.store']);
    $router->patch('/course/tags/{id}', ['uses' => 'CourseTagsController@update', 'as' => 'backend.course.tags.update']);
    $router->delete('/course/tags/{id}', ['uses' => 'CourseTagsController@destroy', 'as' => 'backend.course.tags.destroy']);


    //课程推荐图
    $router->post('/banner/store', ['uses' => 'BannerController@savaBanner', 'as' => 'backend.banner.store']);
    $router->get('/bannerList', ['uses' => 'BannerController@BannerList', 'as' => 'backend.banner.bannerList']);
    $router->put('/updateBanner', ['uses' => 'BannerController@updateBanner', 'as' => 'backend.banner.updateBanner']);
    $router->delete('/delBanner', ['uses' => 'BannerController@delBanner', 'as' => 'backend.banner.delBanner']);

    //助教教师
    $router->post('/assistant/store', ['uses' => 'AssistantController@savaAssistant', 'as' => 'backend.assistant.store']);
    $router->get('/assistantList', ['uses' => 'AssistantController@AssistantList', 'as' => 'backend.assistant.assistantList']);
    $router->put('/updateAssistant', ['uses' => 'AssistantController@updateAssistant', 'as' => 'backend.assistant.updateAssistant']);
    $router->delete('/delAssistant', ['uses' => 'AssistantController@delAssistant', 'as' => 'backend.assistant.delAssistant']);

});


/** 前台接口 */
$router->group(['prefix' => 'api', 'namespace' => 'Web', 'middleware' => 'WebLogin'], function () use ($router) {


    /** 用户 */
    //学员
    $router->post('/student/setStudentToken', 'StudentsController@setStudentToken');                             // 设置学员登录
    $router->get('/student/info', 'StudentsController@info');                                                    // 获取学员详情
    $router->post('/student/save', 'StudentsController@save');                                                   // 修改学员信息
    //教师
    $router->post('/teacher/setTeacherToken', 'TeachersController@setTeacherToken');                             // 设置教师登录
    $router->get('/teacher/info', 'TeachersController@info');                                                    // 获取教师详情
    $router->post('/teacher/save', 'TeachersController@save');                                                   // 修改教师信息
    //用户
    $router->get('/users/getLoginStatus', 'StudentsController@getLoginStatus');                                 // 获取登录状态

//    $router->post('/users/setStudentToken', ['uses' => 'StudentsController@setStudentToken', 'as' => 'setStudentToken']);
//    $router->post('/users/setStudentToken', 'StudentsController@setToken');                           // 设置学员登录
});